<div class="rounded table" style="width: 98%;">
    <table width="100%" cellpadding="0" cellspacing="0" border="0" class="box_top">
        <thead class="thead">
            <tr class="space">
                <th colspan="10">数据备份</th>
            </tr>
        </thead>
    </table>
    <form action="{:U('Admin/Database/doSaveBackup')}" method="post" class="formvalidate">
        <table class="list" cellpadding="0" cellspacing="1" border="0">
            <tbody>
                <tr>
                    <td class="name">
                        <label class="validation"><span class="spanMsg">*</span>每个分卷文件大小：</label>
                    </td>
                    <td>
                        <input type="text" name="sizelimit" id="sizelimit" value="{$sizelimit}" class="input rounded iColorPicker" size="10" required validate="{ required:true,maxlength:30}">&nbsp;K
                    </td>
                    <td class="field">
                        <img title="(推荐{$sizelimit}K以下)" class="title2div" src="__PUBLIC__/Admin/images/icons/icon_help.png" width="16" height="16">				
                    </td>
                </tr>
                <tr>
                    <td class="name" width="150">
                        <label class="validation"><span class="spanMsg">*</span>备份名称：</label>
                    </td>
                    <td>
                        <input type="text" class="input rounded" name="backup_name" id="backup_name" size="30" value="{$backup_name}" style="width:300px;" required validate="{ required:true}">
                    </td>
                    <td class="field"></td>
                </tr>
                <tr>
                    <td class="name" width="150">
                        <label class="validation">
                            <span class="spanMsg">*</span>备份类型：
                        </label>
                    </td>  
                    <td class="rowform">
                        <ul>

                            <li>
                                <label>
                                    <input type="radio" checked="checked" value="all" name="backup_type">全部备份<span style="color:#cecece;">（备份数据库所有表）</span></label>
                            </li>
                            <li>
                                <label>
                                    <input type="radio" value="custom" name="backup_type">自定义备份<span  style="color:#cecece;">（根据自行选择备份数据表）</span></label>
                            </li>
                        </ul>
                    </td>
                    <td class="field">
                        
                    </td>
                </tr>
                <tr id="tables" style="display: none;">
                    <td colspan="3">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="mgr_table">
                            <tbody>
                                <tr align="center" class="thead2">
                                    <td width="5%" height="25"><input type="checkbox" name="checkall" onclick="CheckAllBtn(form)" value="check" checked="checked" class="checkAll" id="checkboxall" data-checklist="checkSon_x" data-direction="x"></td>
                                    <td width="10%" style="text-align: left;">表名</td>
                                    <td width="5%">记录数</td>
                                    <td width="20%">编码</td>
                                    <td width="15%">
                                        数据大小[
                                        <php>if($data_length >= 1024){</php>
                                            {$data_length>>10}KB
                                        <php>}else{</php>
                                            {$data_length}B
                                        <php>}</php>]
                                    </td>
                                    <td width="20%" style="text-align: left;">说明</td>
                                    <td width="25%" class="noborder">操作</td>
                                </tr>
                                <volist name="tables" id="table">
				<tr align="center">
                                    <td height="30"><input type="checkbox" value="{$table.Name}" checked="checked" name="checkall" class="checkSon" data-xid="checkSon_x"></td>
                                    <td style="text-align: left;">{$table.Name}</td>
                                    <td>{$table.Rows}</td>
                                    <td width="20%">{$table.Collation}</td>
                                    <td>
                                        <php>if($table['Data_length'] >= 1024){</php>
                                            {$table['Data_length']>>10}KB
                                        <php>}else{</php>
                                            {$table['Data_length']}B
                                        <php>}</php>
                                    </td>
                                    <td width="20%" style="text-align: left;">{$table['Comment']}</td>
                                    <td class="action">
                                        <span>
                                            [<a href='{:U("Admin/Database/getDbStruct","tbname=$table[Name]")}'>结构</a>]
                                        </span>
                                        <span>
                                            [<a href="javascript:void(0);" onclick="DbAction('REPAIR','{$table.Name}');">修复</a>]
                                        </span>
                                        <span>
                                            [<a href="javascript:void(0);" onclick="DbAction('OPTIMIZE','{$table.Name}');">优化</a>]
                                        </span>
                                    </td>
                                </tr>
                                </volist>
                            </tbody>
                        </table>
                    </td>
                </tr>
            </tbody>
        </table>
        <table class="table top_line">
            <tbody>
                <tr>
                    <td align="left" height="60" colspan="2">
                        <input id="submit" class="submit" name="datasubmit" type="submit" value="提交">
                        <input type="reset" id="reset" class="submit reset" value="重置">
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<script>
    $(document).ready(function(){
        $(".rowform input[name='backup_type']").live('click',function(){
            var val = $(this).val();
            if(val == 'all'){
                $("#tables").fadeOut();
            }else{
                $("#tables").fadeIn();
            }
        });
        
    })    
    
    //修复表
    function DbAction(action,tbname){
        if(tbname == ''){
            showTips(false,"请选中对应表，再操作");
            return false;
        }
        $.ajax({
            url:"{:U('Admin/Database/doDbOperations')}",
            cache:false,
            dataType:'json',
            data:{action:action,tbname:tbname},
            type:'POST',
            success:function(msgObj){
                if(msgObj.status == '1'){
                    showTips(true,msgObj.info);
                    return false;
                }else{
                    showTips(false,msgObj.info);
                    return false;
                }
            }
        });
    }
</script>